import { MigrationInterface, QueryRunner } from "typeorm";

export class InitOneToOne1733032716046 implements MigrationInterface {
    name = 'InitOneToOne1733032716046'

    public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`CREATE TABLE "sample_one_to_one_profile" ("id" SERIAL NOT NULL, "gender" character varying NOT NULL, "photo" character varying NOT NULL, CONSTRAINT "PK_8d32d1462b81f537560806afa7a" PRIMARY KEY ("id"))`);
        await queryRunner.query(`CREATE TABLE "sample_one_to_one_user" ("id" SERIAL NOT NULL, "name" character varying NOT NULL, "profileId" integer, CONSTRAINT "REL_828aab70092591dae9b80717e8" UNIQUE ("profileId"), CONSTRAINT "PK_b2714ea008249b96b8b1a2c09c2" PRIMARY KEY ("id"))`);
        await queryRunner.query(`ALTER TABLE "sample_one_to_one_user" ADD CONSTRAINT "FK_828aab70092591dae9b80717e8b" FOREIGN KEY ("profileId") REFERENCES "sample_one_to_one_profile"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
    }

    public async down(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`ALTER TABLE "sample_one_to_one_user" DROP CONSTRAINT "FK_828aab70092591dae9b80717e8b"`);
        await queryRunner.query(`DROP TABLE "sample_one_to_one_user"`);
        await queryRunner.query(`DROP TABLE "sample_one_to_one_profile"`);
    }

}
